﻿using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using 纸片人.Shaders;

namespace 纸片人.win2dEffectControl.DataClass
{
    public class HighLightRevealEffectData : PixelShaderEffectData
    {




        private Vector2 point=new Vector2(0.5f,0.5f);
        private float radius=0.5f;

        #region  属性
        /// <summary>
        /// 临界点 0-1
        /// </summary>
        public Vector2 Point { get => point; set { point = value; OnPropertyChanged(); SetIsChanges(); } }
        public float Radius { get => radius; set { radius = value; OnPropertyChanged(); SetIsChanges(); } }

        public override ShaderType shaderShaderPath { get; } = ShaderType.HighlightReveal;

        #endregion
        public override ICanvasImage GetEffect(CanvasDevice device, bool compression)
        {
            var source = GetSourceEffect(device, compression);
            if (source == null)
            {
                return null;
            }

            if (shaderCodeBytes == null)
                return null;
            PixelShaderEffect effect = new PixelShaderEffect(shaderCodeBytes)
            {
                Source1 = source,
            };
            effect.Properties["pos"] = new Vector2((float) (Point.X*Size.Width),(float)(point.Y*Size.Height));
            effect.Properties["radius"] =(float)( Size.Width>Size.Height? Radius*Size.Width:Radius*Size.Height);
            return effect;
        }
    }
}